import Vue from 'vue';
import Router from 'vue-router';

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/* Layout */

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: resolve => require(['@/views/login/index.vue'], resolve), hidden: true},
  {path: '/404', component: resolve => require(['@/views/404.vue'], resolve), hidden: true},
  {path: '/', redirect: '/nodes'},
  {
    path: '/',
    meta: {title: 'SC控制台', mould: 'main', icon: 't-app'},
    component: resolve => require(['@/views/index.vue'], resolve),
    children: [

      {
        path: '/whiteLists',
        name: 'whiteList',
        component: resolve => require(['@/views/whiteList/index.vue'], resolve),
        meta: {title: '白名单', mould: 'whiteList', icon: 't-white-list', showAdd: true},
        children: []
      },
      {
        path: '/nodes',
        name: 'node',
        meta: {title: '节点列表', mould: 'node', icon: 't-node'},
        component: resolve => require(['@/views/node/nodeList.vue'], resolve),
        children: []
      },
      {
        path: '/nodes/:nodeId',
        meta: {title: '节点信息', mould: 'node', icon: 't-node'},
        redirect: '/nodes/:nodeId/service',
        component: resolve => require(['@/views/node/show.vue'], resolve),
        children: [
          {
            path: 'service',
            name: 'service',
            component: resolve => require(['@/views/node/node-service.vue'], resolve),
            meta: {title: '服务详情', mould: 'service'}
          },
          {
            path: 'statics',
            name: 'statics',
            component: resolve => require(['@/views/node/node-statics.vue'], resolve),
            meta: {title: '统计', mould: 'statics'}
          },
          {
            path: 'status',
            name: 'status',
            component: resolve => require(['@/views/node/node-status.vue'], resolve),
            meta: {title: '连接状态', mould: 'status'}
          }
        ],
        hidden: true
      },
      {
        path: '/nodelasttimes',
        name: 'nodelasttime',
        meta: {title: '节点事件上次时间', mould: 'nodelast', icon: 't-time'},
        component: resolve => require(['@/views/node/nodelasttime.vue'], resolve),
        children: []
      },
      {
        path: '/nodesOperatorInfos',
        name: 'nodesOperatorInfo',
        meta: {title: '节点事件信息', mould: 'nodesOperatorInfo', icon: 'info'},
        component: resolve => require(['@/views/node/nodesOperatorInfo.vue'], resolve),
        children: []
      },
      {
        path: '/headBeats',
        name: 'headBeat',
        component: resolve => require(['@/views/headBeat/index.vue'], resolve),
        meta: {title: '心跳超时监控', mould: 'headBeat', icon: 't-heat'},
        children: []
      }
    ]
  }

  // {path: '/test', component: resolve => require(['@/views/test.vue'], resolve)}
  // {path: '*', redirect: '/404', hidden: true}
];

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
});

